package models

import (
	"chat/utils"
	"time"

	"gorm.io/gorm"
)

type RoomBasic struct {
	gorm.Model
	Identity string    `json:"identity" gorm:"房间密码"`
	Name     string    `json:"name" gorm:"房间名称"`
	BeginAt  time.Time `json:"begin_at" gorm:"开始时间"`
	EndAt    time.Time `json:"end_at" gorm:"结束时间"`
	CreateId uint      `json:"create_id" gorm:"创建时间"`
}

func (table *RoomBasic) Table() string {
	return "room_basic"
}

func CreateRoom(room *RoomBasic) (RoomBasic, error) {
	utils.Mysql.Table("room_basic").Create(room)
	var room_basic RoomBasic
	err := utils.Mysql.Table("room_basic").Where("id = ?", room.ID).Find(&room_basic).Error
	return room_basic, err
}
